package com.cpr.core.concurrency.waitAndNotify;

import java.util.HashMap;
import java.util.Map;

/**
 * @author Chen Panrui
 * created at 2022/4/16 17:32
 */
public class Control{

    private static final String IN = "in";
    private static final String OUT = "out";

    private String choice;
    private Party party;

    public Control(String choice, Party party){
        this.choice = choice;
        this.party = party;
    }

    public void inOrOut() throws InterruptedException {
        if(IN.equals(choice)){
            party.enterParty();
        } else if(OUT.equals(choice)){
            party.exitParty();
        } else {
            throw new UnsupportedOperationException("我不知道你想进入或者退出party");
        }
        // 线程执行完成，之后存活 1分钟
        Thread.sleep(60 * 1000L);
    }
}
